package com.demo.web.wx;

import com.demo.dto.BaseResult;
import com.demo.dto.ListResult;
import com.demo.dto.Pagination;
import com.demo.entity.Secretary;
import com.demo.service.ISecretaryService;
import com.demo.vo.SecretaryVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/wx/secretary")
public class SecretaryWxController {
    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private ISecretaryService depService;
    
    /**
     * 创建
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/get", method = RequestMethod.GET)
    public BaseResult<Secretary> get(Secretary arg) {
    	Secretary service_res = depService.selectByPrimaryKey(arg.getId());
        BaseResult<Secretary> res = new BaseResult<Secretary>(true, service_res);
        return res;
    }
    
    /***
     * 分页查询
     * @param arg
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/query", method = RequestMethod.GET)
    public ListResult<Secretary> query(SecretaryVo arg) {
        List<Secretary> list = depService.queryByPage(arg);
        int total = depService.queryCount(arg);
        Pagination page = new Pagination(arg.getPage(), total, arg.getSize());
        ListResult<Secretary> res = new ListResult(true, list);
        res.setPage(page);
        return res;
    }
}
